#include <iostream>
using namespace std;

const int N = 505;

int dp[N][N];
char arr[N][N];

int main()
{
    int m, n;
    cin >> m >> n;

    for (int i = 1; i <= m; ++i)
        for (int j = 1; j <= n; ++j)
            cin >> arr[i][j];


    for (int i = 1; i <= m; ++i)
    {
        for (int j = 1; j <= n; ++j)
        {
            int cnt = 0;
            if (arr[i][j] == 'l') cnt = 4;
            else if (arr[i][j] == 'o') cnt = 3;
            else if (arr[i][j] == 'v') cnt = 2;
            else if (arr[i][j] == 'e') cnt = 1;
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + cnt;
        }
    }

    cout << dp[m][n] << endl;
}
